import request from '@/utils/request';

//ehsinfo
export async function addEhsInfo(params: any) {
  return request('/api/device/addEhsInfo', {
    method: 'POST',
    data: params,
  });
}
export async function delEhsInfo(params: any) {
  return request('/api/device/delEhsInfo', {
    method: 'POST',
    data: params,
  });
}
export async function exportEhsInfo(params: any) {
  return request('/api/device/exportEhsInfo', {
    method: 'POST',
    data: params,
    responseType: 'blob',
  });
}
export async function getEhsInfoByPage(params: any) {
  return request('/api/device/getEhsInfoByPage', {
    method: 'POST',
    data: params,
  });
}
export async function updateEhsInfo(params: any) {
  return request('/api/device/updateEhsInfo', {
    method: 'POST',
    data: params,
  });
}
export async function getEhsCommissioners(params: any) {
  return request('/api/device/getEhsCommissioners', {
    method: 'POST',
    data: params,
  });
}
export async function getEhsHandlers(params: any) {
  return request('/api/device/getEhsHandlers', {
    method: 'POST',
    data: params,
  });
}

//ehsitem
export async function addEhsItem(params: any) {
  return request('/api/device/addEhsItem', {
    method: 'POST',
    data: params,
  });
}
export async function delEhsItem(params: any) {
  return request('/api/device/delEhsItem', {
    method: 'POST',
    data: params,
  });
}
export async function exportEhsItem(params: any) {
  return request('/api/device/exportEhsItem', {
    method: 'POST',
    data: params,
    responseType: 'blob',
  });
}
export async function getEhsItemByPage(params: any) {
  return request('/api/device/getEhsItemByPage', {
    method: 'POST',
    data: params,
  });
}
export async function updateEhsItem(params: any) {
  return request('/api/device/updateEhsItem', {
    method: 'POST',
    data: params,
  });
}
export async function getTemplateIDs(params: any) {
  return request('/api/device/getTemplateIDs', {
    method: 'POST',
    data: params,
  });
}
export async function receiveEhsItem(params: any) {
  return request('/api/device/receiveEhsItem', {
    method: 'POST',
    params: {
      templateId: params,
    },
  });
}
//ehsstandard
export async function addEhsStandard(params: any) {
  return request('/api/device/addEhsStandard', {
    method: 'POST',
    data: params,
  });
}

export async function delEhsStandard(params: any) {
  return request('/api/device/delEhsStandard', {
    method: 'POST',
    data: params,
  });
}

export async function exportEhsStandard(params: any) {
  return request('/api/device/exportEhsStandard', {
    method: 'POST',
    data: params,
    responseType: 'blob',
  });
}
export async function getEhsStandardByPage(params: any) {
  return request('/api/device/getEhsStandardByPage', {
    method: 'POST',
    data: params,
  });
}

export async function updateEhsStandard(params: any) {
  return request('/api/device/updateEhsStandard', {
    method: 'POST',
    data: params,
  });
}
//ehsfile
export async function addEhsFile(params: any) {
  return request('/api/device/addEhsFile', {
    method: 'POST',
    data: params,
  });
}

export async function delEhsFile(params: any) {
  return request('/api/device/delEhsFile', {
    method: 'POST',
    data: params,
  });
}

export async function exportEhsFile(params: any) {
  return request('/api/device/exportEhsFile', {
    method: 'POST',
    data: params,
    responseType: 'blob',
  });
}

export async function getEhsFileByPage(params: any) {
  return request('/api/device/getEhsFileByPage', {
    method: 'POST',
    data: params,
  });
}

export async function updateEhsFile(params: any) {
  return request('/api/device/updateEhsFile', {
    method: 'POST',
    data: params,
  });
}
/* export async function uploadEhsFile(params: any) {
  return request('/api/device/uploadEhsFile', {
    method: 'POST',
    data: params,
  });
} */
/* export async function uploadEhsFile(params: any) {
  return request(' /api/device/uploadEhsFile', {
    method: 'POST',
    data: params,
  });
} */

export async function uploadEhsFile(para: any) {
  return request('/api/device/uploadEhsFile', {
    method: 'POST',
    requestType: 'form',
    headers: {
      'Content-Type': 'multipart/form-data; boundary=----WebKitFormBoundaryX72QZDdfwlF5U73J',
    },
    data: para.multipartFile,
    params: {
      ehsitemId: para.ehsitemId,
      memo: para.memo,
      fileName: para.fileName,
    },
  });
}

export default {
  addEhsInfo,
  delEhsInfo,
  exportEhsInfo,
  getEhsInfoByPage,
  updateEhsInfo,
  getEhsCommissioners,
  getEhsHandlers,
  addEhsItem,
  delEhsItem,
  exportEhsItem,
  getTemplateIDs,
  getEhsItemByPage,
  updateEhsItem,
  addEhsStandard,
  receiveEhsItem,
  delEhsStandard,
  exportEhsStandard,
  getEhsStandardByPage,
  updateEhsStandard,
  addEhsFile,
  delEhsFile,
  exportEhsFile,
  getEhsFileByPage,
  updateEhsFile,
  uploadEhsFile,
};
